package com.ruoyi.supermarket.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.supermarket.domain.Vo.ShCPay;
import com.ruoyi.supermarket.domain.Vo.ShCx;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supermarket.domain.Yfpay;
import com.ruoyi.supermarket.service.IYfpayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应付汇总Controller
 * 
 * @author ruoyi
 * @date 2024-05-30
 */
@RestController
@RequestMapping("/supermarket/yfpay")
public class YfpayController extends BaseController
{
    @Autowired
    private IYfpayService yfpayService;

    /**
     * 查询应付汇总列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:list')")
    @GetMapping("/list")
    public TableDataInfo list(Yfpay yfpay)
    {
        startPage();
        List<Yfpay> list = yfpayService.selectYfpayList(yfpay);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:list')")
    @GetMapping("/listFzd")
    public TableDataInfo listFzd(Yfpay yfpay)
    {
        startPage();
        List<Yfpay> list = yfpayService.selectYfpayListFzd(yfpay);
        return getDataTable(list);
    }

    /**
     * 导出应付汇总列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:export')")
    @Log(title = "应付汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Yfpay yfpay)
    {
        List<Yfpay> list = yfpayService.selectYfpayList(yfpay);
        ExcelUtil<Yfpay> util = new ExcelUtil<Yfpay>(Yfpay.class);
        util.exportExcel(response, list, "应付汇总数据");
    }

    /**
     * 获取应付汇总详细信息
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:query')")
    @GetMapping(value = "/{yfpayId}")
    public AjaxResult getInfo(@PathVariable("yfpayId") Long yfpayId)
    {
        return success(yfpayService.selectYfpayByYfpayId(yfpayId));
    }

    /**
     * 新增应付汇总
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:add')")
    @Log(title = "应付汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Yfpay yfpay)
    {
        return toAjax(yfpayService.insertYfpay(yfpay));
    }

    /**
     * 修改应付汇总
     */
//    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:edit')")

    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:fsh')")
    @Log(title = "应付汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Yfpay yfpay)
    {
        return toAjax(yfpayService.updateYfpay(yfpay));
    }

    /**
     * 删除应付汇总
     */
    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:remove')")
    @Log(title = "应付汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yfpayIds}")
    public AjaxResult remove(@PathVariable Long[] yfpayIds)
    {
        return toAjax(yfpayService.deleteYfpayByYfpayIds(yfpayIds));
    }


    //审核
    @PostMapping("/audit")
    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:audit')")
    public AjaxResult audit(@RequestBody ShCPay shCPay)
    {
        return yfpayService.audit(shCPay);
    }


    //核销
    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:hxPay')")
    @PostMapping("/hxPay")
    public AjaxResult hxPay(@RequestBody Yfpay yfpay)
    {
        return yfpayService.hxPay(yfpay);
    }

    //反制单
    @PreAuthorize("@ss.hasPermi('supermarket:yfpay:Fzd')")
    @PostMapping("/Fzd")
    public AjaxResult Fzd(@RequestBody Yfpay yfpay)
    {
        return yfpayService.Fzd(yfpay);
    }

}
